/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.utils;

import com.google.common.collect.Maps;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;

import java.util.Map;

/**
 * Created by cherry on 2016/6/3.
 */
public class SummaryRuleStyle {
    public static Map<String, XSSFCellStyle> getBackStyle (XSSFWorkbook workbook) {
        Map<String, XSSFCellStyle> resultMap = Maps.newHashMap();
        if (resultMap.size() == 0) {
            XSSFCellStyle style = workbook.createCellStyle();
            style.setFillForegroundColor(IndexedColors.SEA_GREEN.getIndex());
            style.setFillPattern(CellStyle.SOLID_FOREGROUND);
            style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
            style.setBorderBottom(XSSFCellStyle.BORDER_THIN); //下边框
            style.setBorderLeft(XSSFCellStyle.BORDER_THIN);//左边框
            style.setBorderTop(XSSFCellStyle.BORDER_THIN);//上边框
            style.setBorderRight(XSSFCellStyle.BORDER_THIN);//右边框
            resultMap.put(ExportLabelConstant.EXPORT_SUMMARY_EXCELLENT, style);

            style = workbook.createCellStyle();
            style.setFillForegroundColor(IndexedColors.SKY_BLUE.getIndex());
            style.setFillPattern(CellStyle.SOLID_FOREGROUND);
            style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
            style.setBorderBottom(XSSFCellStyle.BORDER_THIN); //下边框
            style.setBorderLeft(XSSFCellStyle.BORDER_THIN);//左边框
            style.setBorderTop(XSSFCellStyle.BORDER_THIN);//上边框
            style.setBorderRight(XSSFCellStyle.BORDER_THIN);//右边框
            resultMap.put(ExportLabelConstant.EXPORT_SUMMARY_ADEQUTE, style);

            style = workbook.createCellStyle();
            style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
            style.setFillPattern(CellStyle.SOLID_FOREGROUND);
            style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
            style.setBorderBottom(XSSFCellStyle.BORDER_THIN); //下边框
            style.setBorderLeft(XSSFCellStyle.BORDER_THIN);//左边框
            style.setBorderTop(XSSFCellStyle.BORDER_THIN);//上边框
            style.setBorderRight(XSSFCellStyle.BORDER_THIN);//右边框
            resultMap.put(ExportLabelConstant.EXPORT_SUMMARY_MARGIMAL, style);

            style = workbook.createCellStyle();
            style.setFillForegroundColor(IndexedColors.RED.getIndex());
            style.setFillPattern(CellStyle.SOLID_FOREGROUND);
            style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
            style.setBorderBottom(XSSFCellStyle.BORDER_THIN); //下边框
            style.setBorderLeft(XSSFCellStyle.BORDER_THIN);//左边框
            style.setBorderTop(XSSFCellStyle.BORDER_THIN);//上边框
            style.setBorderRight(XSSFCellStyle.BORDER_THIN);//右边框
            resultMap.put(ExportLabelConstant.EXPORT_SUMMARY_BAD, style);
        }
        return resultMap;
    }
}
